﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views {
    import reprise.ui.*;
    import flash.events.*;
    import flash.display.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.*;
    import net.wooga.pets.interfaces.*;
    import net.wooga.pets.views.components.*;
    import net.wooga.pets.constants.*;
    import org.robotlegs.mvcs.*;

    public class MainViewMediator extends Mediator {

		[Inject]
        public var mainView:MainView;
		[Inject]
        public var userModel:UserModel;
		[Inject]
        public var roomSlotsModel:RoomSlotsModel;
		[Inject]
        public var sunModel:SunModel;
		[Inject]
        public var sessionModel:SessionModel;
		[Inject]
        public var gameStateModel:GameStateModel;
		[Inject]
        public var languageModel:LanguageModel;

        override public function onRegister():void{
            eventMap.mapListener(eventDispatcher, CreationEvent.CREATE_ROOF_DISPLAY, this.createRoof);
            eventMap.mapListener(eventDispatcher, CreationEvent.CREATE_ELEVATOR_ROOF, this.createElevatorRoof);
            eventMap.mapListener(eventDispatcher, CreationEvent.CREATE_ELEVATOR_SHAFT, this.createElevator);
            eventMap.mapListener(eventDispatcher, CreationEvent.CREATE_MAIN_MENU, this.createMainMenu);
            eventMap.mapListener(eventDispatcher, CreationEvent.CREATE_META_MENU, this.createMetaMenu);
            eventMap.mapListener(eventDispatcher, EventConstants.CREATE_COLLECTION_STATUS_DISPLAY, this.createCollectionStatusDisplay);
            eventMap.mapListener(eventDispatcher, CreationEvent.CREATE_BASEMENT, this.createBasement);
            eventMap.mapListener(eventDispatcher, CreationEvent.CREATE_INTERSOL, this.createIntersol);
            eventMap.mapListener(eventDispatcher, CreationEvent.CREATE_CONSTRUCTION_SITES, this.createConstructionSites);
            eventMap.mapListener(eventDispatcher, EventConstants.SHOW_MAIN_VIEW, this.showMainView);
            eventMap.mapListener(eventDispatcher, EventConstants.CREATE_DOCTOR_VIEW, this.createDoctorView);
            eventMap.mapListener(eventDispatcher, EventConstants.CREATE_PATIENT_VIEW, this.createPatientView);
            eventMap.mapListener(eventDispatcher, EventConstants.CREATE_WAITING_PET_VIEW, this.createWaitingPetView);
            eventMap.mapListener(eventDispatcher, EventConstants.CREATE_BABY_VIEW, this.createBabyView);
            eventMap.mapListener(eventDispatcher, EventConstants.CREATE_AVATAR_VIEW, this.createAvatarView);
            eventMap.mapListener(eventDispatcher, EventConstants.CREATE_ROOM_VIEW, this.createRoomView);
            eventMap.mapListener(eventDispatcher, EventConstants.ON_HIDE_PATIENT, this.onHidePatient);
            eventMap.mapListener(eventDispatcher, EventConstants.ON_SHOW_PATIENT, this.onShowPatient);
            eventMap.mapListener(eventDispatcher, EventConstants.DISPLAY_CRITICAL_ERROR, this.onLoadError);
            eventMap.mapListener(eventDispatcher, EventConstants.PLACE_DUMMY_ROOM, this.onPlaceDummyRoom);
            log("on register");
        }
        private function onPlaceDummyRoom(_arg1:InfoEvent):void{
            this.mainView.placeDummyRoom((_arg1.info as MovieClip));
        }
        private function onLoadError(_arg1:InfoEvent):void{
            var _local2:String = this.languageModel.getTextByKey("global_error_message");
            this.mainView.showSystemMessage(_local2);
        }
        private function createIntersol(_arg1:CreationEvent):void{
            var _local2:String = _arg1.body.id;
            var _local3:Number = _arg1.body.x;
            var _local4:Number = _arg1.body.y;
            var _local5:String = _arg1.body.linkageId;
            this.mainView.createIntersol(_local2, _local3, _local4, _local5);
        }
        private function createBasement(_arg1:CreationEvent):void{
            var _local2:String = _arg1.body.id;
            var _local3:Number = _arg1.body.x;
            var _local4:Number = _arg1.body.y;
            var _local5:String = _arg1.body.linkageId;
            this.mainView.createBasement(_local2, _local3, _local4, _local5);
        }
        private function createMetaMenu(_arg1:CreationEvent):void{
            this.mainView.createMetaMenu();
        }
        private function createCollectionStatusDisplay(_arg1:InfoEvent):void{
            this.mainView.createCollectionStatus();
        }
        private function createAvatarView(_arg1:InfoEvent):void{
            var _local2:IActing = IActing(_arg1.info);
            this.mainView.createAvatarView(_local2.id, _local2.type, !(this.gameStateModel.isFacadeVisible));
        }
        private function createBabyView(_arg1:InfoEvent):void{
            var _local2:IActing = IActing(_arg1.info);
            this.mainView.createBabyView(_local2.id, (_local2.type + "Baby"), !(this.gameStateModel.isFacadeVisible));
        }
        private function createPatientView(_arg1:InfoEvent):void{
            var _local2:ITreatable = ITreatable(_arg1.info);
            this.mainView.createPatientView(_local2.id, (_local2.type + _local2.diseaseName), !(this.gameStateModel.isFacadeVisible));
        }
        private function createWaitingPetView(_arg1:InfoEvent):void{
            var _local2:IActing = (_arg1.info as IActing);
            this.mainView.createWaitingPetView(_local2.id, _local2.type, !(this.gameStateModel.isFacadeVisible));
        }
        private function removeWaitingPetView(_arg1:InfoEvent):void{
            var _local2:IActing = (_arg1.info as IActing);
        }
        private function createRoomView(_arg1:InfoEvent):void{
            var _local2:IArea = IArea(_arg1.info);
            var _local3:Boolean = this.gameStateModel.isFacadeVisible;
            if ((_local2 is IRoom)){
                _local3 = ((IRoom(_local2).hasFacade) && (this.gameStateModel.isFacadeVisible));
            };
            this.mainView.removeDummyRoom((GameConstants.ROOM_DUMMY + IRoom(_local2).slotId));
            this.mainView.createRoomView(_local2.id, _local2.type, _local3, this.gameStateModel.isBuildMode);
        }
        private function createDoctorView(_arg1:InfoEvent):void{
            var _local2:ITreating = ITreating(_arg1.info);
            this.mainView.createDoctorView(_local2.id, (_local2.type + "Doctor"), !(this.gameStateModel.isFacadeVisible));
        }
        private function showMainView(_arg1:Event):void{
            UIComponent(getViewComponent()).show();
        }
        private function hideView(_arg1:Event):void{
            UIComponent(getViewComponent()).hide();
        }
        private function createRoof(_arg1:CreationEvent):void{
            var _local2:String = _arg1.body.id;
            var _local3:Number = _arg1.body.x;
            var _local4:Number = _arg1.body.y;
            var _local5:String = _arg1.body.linkageId;
            this.mainView.createRoofDisplay(_local2, _local3, _local4, _local5);
        }
        private function createElevator(_arg1:CreationEvent):void{
            var _local2:String = (_arg1.body.id as String);
            var _local3:int = (_arg1.body.x as int);
            var _local4:int = (_arg1.body.y as int);
            var _local5:String = (_arg1.body.linkageId as String);
            this.mainView.createElevatorShaft(_local2, _local3, _local4, _local5, this.gameStateModel.isFacadeVisible);
        }
        private function createElevatorRoof(_arg1:CreationEvent):void{
            var _local2:String = (_arg1.body.id as String);
            var _local3:Number = _arg1.body.x;
            var _local4:Number = _arg1.body.y;
            var _local5:String = (_arg1.body.linkageId as String);
            this.mainView.createElevatorRoof(_local2, _local3, _local4, _local5);
        }
        private function createMainMenu(_arg1:CreationEvent):void{
            this.mainView.createMainMenu();
        }
        private function createConstructionSites(_arg1:CreationEvent):void{
            this.mainView.createConstructionSite();
        }
        private function onHidePatient(_arg1:InfoEvent):void{
            this.mainView.handlePatient(false, DisplayObject(_arg1.info));
        }
        private function onShowPatient(_arg1:InfoEvent):void{
            this.mainView.handlePatient(true, DisplayObject(_arg1.info));
        }

    }
}//package net.wooga.pets.views 
